<?php

namespace common\models\Institution;

use Yii;

/**
 * This is the model class for table "institution".
 *
 * @property integer $id
 * @property string $title
 * @property string $subhead
 * @property string $intro
 * @property string $img
 * @property string $file
 * @property string $cover
 * @property string $author
 * @property string $comefrom
 * @property string $link
 * @property string $content
 * @property string $seocontent
 * @property string $seokeyword
 * @property string $isrecom
 * @property integer $status
 * @property integer $push
 * @property integer $push_status
 * @property integer $created_at
 * @property integer $updated_at
 * @property string $category_id
 * @property string $optiontag
 * @property integer $front_show
 */
class Institution extends \yii\db\ActiveRecord
{


    const STATUS_DELETED = 0;
    const STATUS_ACTIVE = 10;
    private $_statusLabel;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'institution';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title', 'created_at'], 'required'],
            [['intro', 'content', 'optiontag'], 'string'],
            [['status','front_show'], 'integer'],
            [['title', 'img', 'file', 'cover', 'author', 'comefrom', 'link', 'seocontent', 'seokeyword', 'isrecom'], 'string', 'max' => 255],
            [['created_at'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
          'id' => Yii::t('app', '制度列表'),
            'title' => Yii::t('app', '制度名称'),
            'intro' => Yii::t('app', '制度简介'),
            'img' => Yii::t('app', '制度图片'),
            'file' => Yii::t('app', '制度文件上传'),
            'cover' => Yii::t('app', '图片截取'),
            'author' => Yii::t('app', '作者'),
            'comefrom' => Yii::t('app', '来源'),
            'link' => Yii::t('app', '制度信息外链'),
            'content' => Yii::t('app', '详细介绍'),
            'seocontent' => Yii::t('app', 'SEO描述'),
            'seokeyword' => Yii::t('app', 'SEO关键字'),
            'isrecom' => Yii::t('app', '是否推荐'),
            'status' => Yii::t('app', '状态'),
            'created_at' => Yii::t('app', '创建时间'),
        ];
    }
    /**
     * @inheritdoc
     */
    public function getStatusLabel()
    {
        if ($this->_statusLabel === null) {
            $statuses = self::getArrayStatus();
            $this->_statusLabel = array_key_exists($this->status,self::getArrayStatus()) ? $statuses[$this->status] : '无';
        }
        return $this->_statusLabel;
    }
    /**
     * @inheritdoc
     */
    public static function getArrayStatus()
    {
        return [
            self::STATUS_ACTIVE => Yii::t('app', 'STATUS_ACTIVE'),
            self::STATUS_DELETED => Yii::t('app', 'STATUS_INACTIVE'),

        ];
    }
}
